package util;




import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
 * 
 * @author JGH
 * 
 */
public class BaseDao {


	


	
	public static final String CLASSNAME="oracle.jdbc.driver.OracleDriver";
	
	public static final String URL="jdbc:oracle:thin:@192.168.7.8:1521:xe";
	
	public static final String USERNAME="jgh";
	
	public static final String PASSWORD="admin";
	


	
	public static Connection openConnection(){
	
		Connection conn=null;
		
		try {
			
			Class.forName(CLASSNAME);
			
			conn= DriverManager.getConnection(URL, USERNAME, PASSWORD);
		//	System.out.println("success!");
		}  catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		return conn;
	}
	

	
	public static void closeAll(Connection conn, PreparedStatement pstm, ResultSet rs) {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if (pstm != null) {
			try {
				pstm.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if (conn != null) {
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}


	public static void main(String[] args) {
		System.out.println(openConnection());
	}
	
	

}
